﻿@using KRM.Core
@model KRM.Core.tblOrderItem
@{
    ViewBag.Title = "PRE-RDM FAC CHECKLIST";
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
    var hasPhoto = new KRMEntities().tblOrderItemPhotos.Any(a => a.OrderItemID == Model.OrderItemID);
}
<script>
    $(document).ready(function () {
        App.blockUI($('.checklistquestionnaire'), false);
        $.ajax({
            url: '/rdm/LoadNewQuestion?reasonid=' + $("#ReasonID").val(),
            success: function (data) {
                $(".checklistquestionnaire").html(data);
            }
        });
        
        $("#ReasonID").change(function () {
            App.blockUI($('.checklistquestionnaire'), false);
            $.ajax({
                url: '/rdm/LoadNewQuestion?reasonid=' + $("#ReasonID").val(),
                success: function (data) {
                    $(".checklistquestionnaire").html(data);
                }
            });
            if ($(this).val() == 23) {
                $(".showphoto").show();
            } else {
                $(".showphoto").hide();
            }
        });
    });
</script>
<div style="padding: 10px 20px 0 20px; font-size: 12px">
    <form action="/rdm/addquestionnaireform" method="POST" class="addquestionaireform">
        @Html.Partial("Partial/_MessageResult")
        <input type="hidden" value="@Model.OrderItemID" id="OrderItemID" name="OrderItemID"/>
        <input type="hidden" value="@Model.Order.OrderRef" name="OrderRef"/>
        <div class="row-fluid">
            <p>To add an RDM for a : @Model.ProductOption please fill in the following check list and Pre-RDM Questionnaire:</p>
        </div>
        <div class="row-fluid">
            <div class="span1">Reason</div>
            <div class="span4">
                @Html.DropDownList("ReasonID", null, new { required = "required", @class = "input-block-level" })
                <div class="showphoto" style="display: none; font-weight: bold">
                @if (hasPhoto)
                {
                    <a href="/orderview/viewphoto?orderitemid=@Model.OrderItemID" target="_blank">See photos</a>
                }
            </div>
            </div>
            <div class="span1"></div>
            <div class="span2">Reason detail</div>
            <div class="span4">
                @Html.DropDownList("ReasonDetailID", null, "Please select a Reason Detail", new { required = "required", @class = "input-block-level" })
            </div>
        </div>
        Check List:
        <div class="border-padding10 checklistquestionnaire">
        </div>
        <p>Other comment - describe any damages and possible causes :</p>
        <div class="row-fluid">
            <textarea class="input-block-level" name="OtherComments"></textarea>
        </div>
        <div class="row-fluid">
            <div class="span12 text-center" style="margin-top: 10px">
                <input type="button" class="btn  btn-primary btn-issueresolve" value="Issue Resolvel" />
                <input type="button" class="btn btn-primary btn-generaterdm" style="margin: 0 20px" value="Generate RDM" />
                <input type="button" value="Save" class="btn btn-primary btn-addquestionnaire" />
                <button class="btn" onclick="javascript:window.close();" style="margin-left: 20px">Cancel</button>
            </div>
        </div>
    </form>
</div>
